package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysCompanyInfo;
import com.ruoyi.system.service.ISysCompanyInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业基本现状Controller
 * 
 * @author ruoyi
 * @date 2023-06-09
 */
@Api(tags = "企业基本现状")
@RestController
@RequestMapping("/system/info")
public class SysCompanyInfoController extends BaseController
{
    @Autowired
    private ISysCompanyInfoService sysCompanyInfoService;

    /**
     * 查询企业基本现状列表
     */
    @ApiOperation(value = "查询企业基本现状列表")
 //   @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public AjaxResult list(SysCompanyInfo sysCompanyInfo)
    {

        List<SysCompanyInfo> list = sysCompanyInfoService.selectSysCompanyInfoList(sysCompanyInfo);
        return AjaxResult.success(list);
    }

    /**
     * 导出企业基本现状列表
     */
    @ApiOperation(value = "导出企业基本现状列表")
  //  @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "企业基本现状", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCompanyInfo sysCompanyInfo)
    {
        List<SysCompanyInfo> list = sysCompanyInfoService.selectSysCompanyInfoList(sysCompanyInfo);
        ExcelUtil<SysCompanyInfo> util = new ExcelUtil<SysCompanyInfo>(SysCompanyInfo.class);
        util.exportExcel(response, list, "企业基本现状数据");
    }

    /**
     * 获取企业基本现状详细信息
     */
    @ApiOperation(value = "获取企业基本现状详细信息(根据企业id)")
   // @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{deptId}")
    public AjaxResult getInfo(@PathVariable("deptId") Long deptId)
    {
        return AjaxResult.success(sysCompanyInfoService.selectSysCompanyInfoByCompanyId(deptId));
    }

    /**
     * 新增企业基本现状
     */
    @ApiOperation(value = "新增企业基本现状")
  //  @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "企业基本现状", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysCompanyInfo sysCompanyInfo)
    {
        return toAjax(sysCompanyInfoService.insertSysCompanyInfo(sysCompanyInfo));
    }

    /**
     * 修改企业基本现状
     */
    @ApiOperation(value = "修改企业基本现状")
 //   @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "企业基本现状", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCompanyInfo sysCompanyInfo)
    {
        return toAjax(sysCompanyInfoService.updateSysCompanyInfo(sysCompanyInfo));
    }

    /**
     * 删除企业基本现状
     */
    @ApiOperation(value = "删除企业基本现状")
  //  @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "企业基本现状", businessType = BusinessType.DELETE)
	@DeleteMapping("/{companyIds}")
    public AjaxResult remove(@PathVariable Long[] companyIds)
    {
        return toAjax(sysCompanyInfoService.deleteSysCompanyInfoByCompanyIds(companyIds));
    }
}
